import React, { Component } from 'react'

export default class Timer extends Component {
  state={time: ''}
  componentDidMount(){
    this.timerId = setInterval(()=>{
      console.log(123)
      const date = new Date();
      this.setState({time: date.toLocaleTimeString()})
    },1000)
  }
  componentWillUnmount(){
    console.log('unmount')
    clearInterval(this.timerId)
  }
  render() {
    return (
      <div>{this.state.time}</div>
    )
  }
}
